Page({
  data: {
    type: '',
    disabilityLevels: ['1级', '2级', '3级', '4级', '5级', '6级'],
    currentLevel: 0,
    salary: 0,
    leaveMonths: 0,
    result: null,
    detail: {}
  },

  onLoad(options) {
    this.setData({ type: options.type });
  },

  levelChange(e) {
    this.setData({ currentLevel: e.detail.value });
  },

  salaryInput(e) {
    this.setData({ salary: parseFloat(e.detail.value) || 0 });
  },

  leaveInput(e) {
    this.setData({ leaveMonths: parseInt(e.detail.value) || 0 });
  },

  calculate() {
    // 实际计算应根据最新工伤保险条例
    const disabilityCompensation = [27, 25, 23, 21, 18, 16][this.data.currentLevel] * this.data.salary;
    const leavePay = this.data.leaveMonths * this.data.salary;
    
    this.setData({
      result: disabilityCompensation + leavePay,
      detail: {
        disability: disabilityCompensation,
        leave: leavePay
      }
    });
  }
})